package com.niit.config;

import com.niit.beans.Car;
import com.niit.beans.Dog;
import com.niit.beans.Sheep;
import com.niit.beans.User;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;

/**
 * @ProjectName: springBoot3-demo
 * @Package: com.niit.config
 * @ClassName: AppCconfigTwo
 * @Author: zjh
 * @description: TODO
 * @date: 2024/1/2 9:33
 * @version: 1.0
 */
@SpringBootConfiguration
//@EnableConfigurationProperties(Sheep.class)
public class AppConfigTwo {
    @ConditionalOnClass(name="com.alibaba.druid.FastsqlException")
    @Bean
    public Car car01(){
        return new Car();
    }
    @ConditionalOnMissingClass(value="com.alibaba.druid.FastsqlException")
    @Bean
    public Dog dog01(){
        return new Dog();
    }
    @ConditionalOnBean(value = Dog.class)
    @Bean("zhangsan")
    public User user(){
        return new User();
    }
    @ConditionalOnMissingBean(value = Dog.class)
    @Bean("lisi")
    public User user1(){
        return new User();
    }
}
